package com.ffcs.web.utils;

import java.io.UnsupportedEncodingException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ChinaeseUtil {

	/**
	 * 判断是否是中文 zhaoyingguang 2015/09/11
	 */
	public static boolean isChineseChar(String str){
	       boolean temp = false;
	       Pattern p=Pattern.compile("[\u4e00-\u9fa5]");
	       Matcher m=p.matcher(str);
	       if(m.find()){
	           temp =  true;
	       }
	       System.out.println(temp);
	       return temp;
	       
	 }
	
	public static String CharTOChinaese(String str){
		if(!isChineseChar(str)){
			try {
				str=new String(str.getBytes("ISO-8859-1"),"UTF-8");
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			return str;
		}
		return str;
	}
}
